package com.neighbor.neighborhooduser.pojo;

import lombok.Data;
import java.util.Date;

@Data
public class OrderWithItemDTO {
    private Integer orderId;
    private String orderNumber;

    // 卖家信息
    private Integer sellerId;
    private String sellerName;
    private String sellerBuilding;

    // 买家信息
    private Integer buyerId;
    private String buyerName;
    private String buyerBuilding;

    // 物品信息
    private Integer itemId;
    private String title;

    // 订单信息
    private Byte status;
    private Integer rentDays;
    private Date startDate;
    private Date endDate;
    private Double price;

    // 状态描述（方便前端直接使用）
    public String getStatusDesc() {
        if (status == null) return "未知状态";

        switch(status) {
            case 1: return "待确认";
            case 2: return "进行中";
            case 3: return "已完成";
            case 4: return "已取消";
            default: return "未知状态";
        }
    }

    // 判断当前用户角色（用于前端展示）
    public String getUserRole(Integer currentUserId) {
        if (sellerId != null && sellerId.equals(currentUserId)) {
            return "卖家";
        } else if (buyerId != null && buyerId.equals(currentUserId)) {
            return "买家";
        }
        return "未知";
    }

    // 计算总租金（可选）
    public Double getTotalRent() {
        if (price != null && rentDays != null) {
            return price * rentDays;
        }
        return 0.0;
    }
}